package com.pinxixi.goods.mapper;

import com.pinxixi.framework.domain.goods.Goods;
import com.pinxixi.framework.domain.goods.GoodsDesc;
import com.pinxixi.framework.domain.goods.Item;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface GoodsMapper {

    void addGoods(Goods goods);

    void addGoodsDesc(GoodsDesc goodsDesc);

    void addItem(Item item);

    @Select("select id,goods_name goodsName,price,category1_id category1Id,category2_id category2Id,category3_id category3Id,audit_status auditStatus from tb_goods")
    List<Goods> findPage();

    void commitApply(Long[] ids);

    void goodsApply(Map map);

    @Select("select id,goods_name goodsName,brand_id brandId,caption,category1_id category1Id,category2_id category2Id,category3_id category3Id,price,type_template_id typeTemplateId from tb_goods where id=#{id}")
    Goods findGoods(Long id);

    @Select("select goods_id goodsId,introduction,specification_items specificationItems,custom_attribute_items customAttributeItems,item_images itemImages,package_list packageList,sale_service saleService  from tb_goods_desc where goods_id=#{id}")
    GoodsDesc findGoodsDesc(Long id);

    @Select("select id,title,price,num,image,categoryId categoryid,status,create_time createTime,update_time updateTime,goods_id goodsId,category,brand,spec,seller_id sellerId,seller from tb_item where goods_id=#{id}")
    List<Item> findItemByGoodsId(Long id);

    @Select("select id,title,price,num,image,categoryId categoryid,status,create_time createTime,update_time updateTime,goods_id goodsId,category,brand,spec from tb_item where id=#{id}")
    Item findItemById(Long id);
}
